﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace Dal
{
    public class ProOtherInfo
    {
        public static DataTable Single(string strCon,string whereStr)
        {
            DataTable dt = new DataTable();
            SqlParameter[] pars = { new SqlParameter("@WhereStr",whereStr) };
            try
            {
                dt = SqlHelper.ExecuteDataTable(Public.DataProtector.DecryptString(strCon), CommandType.StoredProcedure, "SP_ProOtherInfo_Search_SINGLE", pars);
            }
            catch (Exception)
            { 
                throw;
            }
            return dt;
        }

        public static DataTable MULTIPLE(string strCon,int proId) 
        {
            DataTable dt = new DataTable();
            SqlParameter[] par = { new SqlParameter("@ProId", proId) };
            try
            {
                dt = SqlHelper.ExecuteDataTable(Public.DataProtector.DecryptString(strCon), CommandType.StoredProcedure, "SP_ProOtherInfo_MULTIPLE_ProId", par);
            }
            catch (Exception)
            {
                throw;
            }
            return dt;
        }

        public static int Delete(string strCon,int pkid)
        {
            int rtn = 0;
            SqlParameter[] par = { new SqlParameter("@PKID", pkid) };
            try
            {
                rtn = SqlHelper.ExecuteNonQuery(Public.DataProtector.DecryptString(strCon), CommandType.StoredProcedure, "SP_ProOther_DELETE", par);
            }
            catch (Exception)
            {
                throw;
            }
            return rtn;
        }

        public static int Insert(string strCon,int proId,string bigImgUrl,string mediumImgUrl,string smallImgUrl) 
        {
            int rtn = 0;
            SqlParameter[] pars = { 
                                    new SqlParameter("@ProId",proId),
                                    new SqlParameter("@OtherBigImgURL",bigImgUrl),
                                    new SqlParameter("@OtherMediumImgURL",mediumImgUrl),
                                    new SqlParameter("@OtherSmallImgURL",smallImgUrl)
                                  };
            try
            {
                rtn = SqlHelper.ExecuteNonQuery(Public.DataProtector.DecryptString(strCon), CommandType.StoredProcedure, "SP_ProOtherInfo_INSERT", pars);
            }
            catch (Exception)
            {
                throw;
            }
            return rtn;
        }

        public static int Update(string strCon, int pkid, string bigImgUrl, string mediumImgUrl, string smallImgUrl)  
        {
            int rtn = 0;
            SqlParameter[] pars = { 
                                    new SqlParameter("@PKID",pkid),
                                    new SqlParameter("@OtherBigImgURL",bigImgUrl),
                                    new SqlParameter("@OtherMediumImgURL",mediumImgUrl),
                                    new SqlParameter("@OtherSmallImgURL",smallImgUrl)
                                  };
            try
            {
                rtn = SqlHelper.ExecuteNonQuery(Public.DataProtector.DecryptString(strCon), CommandType.StoredProcedure, "SP_ProOtherInfo_Update", pars);
            }
            catch (Exception)
            {
                throw;
            }
            return rtn;
        }

        
    }
}
